package top.yqingyu.trans$client.api;


public class ConnectionFactory {

    private final ConnectionConfig config;
    private ConnectionPool pool;


    public ConnectionFactory(ConnectionConfig config) throws Exception {
        this.config = config;
        if (this.config.pooling) {
            pool = new ConnectionPool(config);
        }
    }

    public Connection getConnection() throws Exception {
        if (config.pooling) {
            return pool.next();
        }
        return Connection.getInstance(config);
    }

}
